define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'goods.category/index',
        add_url: 'goods.category/add',
        edit_url: 'goods.category/edit',
        delete_url: 'goods.category/delete',
        export_url: 'goods.category/export',
        modify_url: 'goods.category/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh','add','delete'],
                cols: [[
                    {type: 'checkbox'},
                    // {field: 'id', title: 'id',hide:true},
                    {field: 'name', title: '分类名称',align: 'left'},
                    {field: 'shop.name', title: '所属店铺'},

                    {field: 'create_time', title: '添加时间',search:false},
                    {
                        width: 200,
                        title: '操作',
                        align: 'right',
                        // templet: ea.table.tool,
                        templet: function (k, v) {
                            if (k.pid != 0) {
                                v.operat[0].splice(0,1);
                            }
                            // console.log(k, v);
                            return ea.table.tool(k,v);
                        },
                        operat: [
                            [
                                {
                                text: '添加下级',
                                url: init.add_url,
                                method: 'open',
                                auth: 'add',
                                class: "layui-btn layui-btn-xs layui-btn-normal ",
                                extend: 'data-full="true"',
                            }, {
                                text: '编辑',
                                url: init.edit_url,
                                method: 'open',
                                auth: 'edit',
                                class: 'layui-btn layui-btn-xs layui-btn-success',
                                extend: 'data-full="true"',
                            }],
                            'delete'
                        ]
                    }
                ]],
				done: function (){
                //     $(".layui-table-body>table>tbody>tr").each(function (index, val) {
                //         $($(".layui-table-fixed .layui-table-body table tr")[index]).height($(val).height());
                //     });
                },
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});